package edu.gatech.cs2340.bytebankers.presenter;

import edu.gatech.cs2340.bytebankers.notifications.GameEvents;
import edu.gatech.cs2340.bytebankers.notifications.Notifier;
import edu.gatech.cs2340.bytebankers.view.ITownView;
import edu.gatech.cs2340.bytebankers.model.Journey;

public class TownPresenter extends Notifier implements ITownPresenter {
	
	Journey journey;
	
	/**
	 * Constructs a new TownPresenter and passes in the model(Journey, in this case)
	 * @param journey - data model
	 */
	public TownPresenter(Journey journey){
		this.journey = journey;
	}

	@Override
	public void OnContinueClick() {
		this.sendNotification(GameEvents.TOWN_CONTINUE);
	}

	/**
     * This method will send a notification to open Menu.
     */
	public void onMenuClick() {
		this.sendNotification(GameEvents.MENU_OPENED);
	}

	@Override
	public void onStoreclick() {
		this.sendNotification(GameEvents.STORE_OPENED);
	}

	@Override
	public void setView(ITownView view) {
		if(journey.getlastLocation() == null) {
			sendNotification(GameEvents.WINNING);
		} else {
			view.setHasStore(journey.getlastLocation().hasStore());
			view.setTownName(journey.getlastLocation().getName());
		}
		
	}

}
